package easy;

public class Solution_1184 {

    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
        if (start > destination) {
            return distanceBetweenBusStops(distance, destination, start);
        }
        int length = distance.length;
        int[] arr = new int[length];
        arr[0] = 0;
        for (int i = 1; i < length; i++) {
            arr[i] = arr[i - 1] + distance[i - 1];
        }
        int min = arr[destination] - arr[start];
        return Math.min(min, arr[length - 1] - min + distance[length - 1]);
    }

    public static void main(String[] args) {
        Solution_1184 model = new Solution_1184();
        System.out.println(model.distanceBetweenBusStops(new int[]{1,2,3,4}, 0, 3));
    }
}
